package cn.starlightsoftware.sherly.convertor;

import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.starlightsoftware.sherly.controller.admin.user.vo.UserRoleRespDTO;
import cn.starlightsoftware.sherly.db.model.permission.UserRoleDO;
import cn.starlightsoftware.sherly.utils.StreamUtil;

import java.util.List;

/**
 * @author 谷子毅
 * @date 2024/4/27
 */
@Mapper
public interface UserConvertor {

    UserConvertor UserConvertor = Mappers.getMapper(UserConvertor.class);

    static UserRoleRespDTO buildUserRoleRespVO(List<UserRoleDO> userRoleList) {
        return new UserRoleRespDTO().setRoleIds(StreamUtil.toList(userRoleList, UserRoleDO::getRoleId));
    }
}
